#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QTime>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    //启动定时器事件
    timeid=startTimer(1000);
    dateid=startTimer(1000*24*60*60);
    ui->label->setText(QDate::currentDate().toString("yyyy-MM-dd"));
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::timerEvent(QTimerEvent *e)
{
    if(e->timerId()==timeid){
        ui->lcdNumber->display(QTime::currentTime().toString("hh:mm:ss"));
    }
    if(e->timerId()==dateid){
        ui->label->setText(QDate::currentDate().toString("yyyy-MM-dd"));
    }
}

void MainWindow::on_stop_timer_clicked()
{

    killTimer(timeid);
}
